home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / xsw / mystreams.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-05  |  15.9 KB  |  488 lines

  1.  
  2. /*
  3.  *    @(#) mystreams.c 12.1 95/07/05 SCOINC
  4.  */
  5. /***************************************************************************
  6.  *
  7.  *    Copyright (c) 1990-1993        The Santa Cruz Operation, Inc.
  8.  *
  9.  *    All rights reserved.  No part of this program or publication may be
  10.  *    reproduced, transmitted, transcribed, stored in a retrieval system,
  11.  *    or translated into any language or computer language, in any form or
  12.  *    by any means, electronic, mechanical, magnetic, optical, chemical,
  13.  *    biological, or otherwise, without the prior written permission of:
  14.  *
  15.  *        The Santa Cruz Operation , Inc.        (408) 425-7222
  16.  *        400 Encinal St., Santa Cruz, California 95060 USA
  17.  *
  18.  **************************************************************************/
  19. /*
  20.  * Modification History
  21.  *
  22.  * S004, 25-Oct-93, rickra
  23.  *     Added 32v5 streams stuff.
  24.  *
  25.  * S003, 25-Oct-93, rickra
  26.  *     Multiplied nqueue info by 2 since in the kernel, queues are allocated
  27.  *    in pairs....
  28.  *
  29.  * S002, 27-May-93, rickra
  30.  *     Added support for pixmap.
  31.  *
  32.  * S001, 01-Jan-93, rickra
  33.  *     Added support for seperate windows.
  34.  *     Made code for stremas blocks a function, to reduce code...
  35.  *
  36.  * S000, 30-Sep-92, rickra
  37.  *     Added copyright and modification history
  38.  */
  39. /*+-------------------------------------------------------------------------
  40.     streams.c - XSW streams display handler
  41.  
  42.   Defined functions:
  43.     draw_streams_literals(x,y)
  44.     update_streams()
  45.  
  46. --------------------------------------------------------------------------*/
  47. /*+:EDITS:*/
  48. #include <X11/Xlib.h>
  49. #include <X11/Xutil.h>
  50. #include <X11/Intrinsic.h>
  51. #include <X11/Shell.h>
  52. #include <Xm/Xm.h>
  53. #include <Xm/MainW.h>
  54. #include <Xm/DrawingA.h>
  55.  
  56. #include "include/unixincs.h"
  57. #include "include/buttons.h"
  58. #include "include/xsw.h"
  59.  
  60. extern struct NetworkXswStruct *current_server;
  61.  
  62.  
  63. extern int      must_be_32v5;
  64.  
  65. int             streams_tlx;
  66. int             streams_tly;
  67.  
  68.  
  69.  
  70. typedef struct mystreamlist
  71. {
  72.   char           *stream_name;
  73. }               streams_list;
  74.  
  75. int             stream_buf_start = 4;    /* Set to first stream buffer in name
  76.                      * list */
  77. static streams_list mystream_list[] =
  78. {
  79.   {"NSTREAM         "},
  80.   {"NQUEUE          "},
  81.   {"MBLOCK          "},
  82.   {"DBLOCK          "},
  83.   {"NBLK4           "},
  84.   {"NBLK16          "},
  85.   {"NBLK64          "},
  86.   {"NBLK128         "},
  87.   {"NBLK256         "},
  88.   {"NBLK512         "},
  89.   {"NBLK1024        "},
  90.   {"NBLK2048        "},
  91.   {"NBLK4096        "}
  92. };
  93.  
  94. int             stream_buf_start32v5 = 3;    
  95.  
  96. static streams_list mystream_list32v5[] =
  97. {
  98.   {"NSTREAM         "},
  99.   {"NQUEUE          "},
  100.   {"MBLOCK          "},
  101.   {"BUFFFER HEADERS "},
  102.   {"NBLK16          "},
  103.   {"NBLK128         "},
  104.   {"NBLK256         "},
  105.   {"NBLK512         "},
  106.   {"NBLK1K          "},
  107.   {"NBLK2K          "},
  108.   {"NBLK4K          "},
  109.   {"NBLK8K          "},
  110.   {"NBLK16K         "},
  111.   {"NBLK32K         "},
  112.   {"NBLK64K         "},
  113.   {"NBLK128K        "},
  114.   {"NBLK256K        "},
  115.   {"NBLK512K        "}
  116. };
  117. void
  118. update_streams_buffers (window, display, gc, DrawAreaXYWH, pixmap, x, y, i)
  119.      Window          window;
  120.      Display        *display;
  121.      GC              gc;
  122.      XWindowAttributes DrawAreaXYWH;
  123.      Pixmap          pixmap;
  124.  
  125.  
  126.      int             x;
  127.      int             y;
  128.      int             i;
  129.  
  130. {
  131.   int             configured = 0;
  132.   int             temp_int;
  133.   unsigned long   pixel;
  134.  
  135.   struct mystreamlist  *stream_list;
  136.  
  137.   int             buf_start = 4;    
  138.  
  139.  
  140.   if ( current_server -> os_version == 0 )
  141.   {
  142.  
  143.   stream_list = *(&mystream_list);
  144.   buf_start = stream_buf_start;    
  145.  
  146.   switch (i)
  147.     {
  148.  
  149.     case 0:
  150.       configured = current_server -> my_v -> v_nblk4;
  151.       break;
  152.     case 1:
  153.       configured = current_server -> my_v -> v_nblk16;
  154.       break;
  155.     case 2:
  156.       configured = current_server -> my_v -> v_nblk64;
  157.       break;
  158.     case 3:
  159.       configured = current_server -> my_v -> v_nblk128;
  160.       break;
  161.     case 4:
  162.       configured = current_server -> my_v -> v_nblk256;
  163.       break;
  164.     case 5:
  165.       configured = current_server -> my_v -> v_nblk512;
  166.       break;
  167.     case 6:
  168.       configured = current_server -> my_v -> v_nblk1024;
  169.       break;
  170.     case 7:
  171.       configured = current_server -> my_v -> v_nblk2048;
  172.       break;
  173.     case 8:
  174.       configured = current_server -> my_v -> v_nblk4096;
  175.       break;
  176.  
  177.     }
  178.   }
  179.   else
  180.   if ( current_server -> os_version == 1 )
  181.   {
  182.  
  183.     stream_list = *(&mystream_list32v5);
  184.  
  185.     buf_start = stream_buf_start32v5;    
  186.  
  187.     configured = current_server -> pagest->alc[i];
  188.  
  189.   }
  190.  
  191.  
  192.   disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, colorLabel.pixel,   stream_list[i + buf_start].stream_name);
  193.   x += (FWIDTH * 16);
  194.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorStaticNumeric.pixel, configured);
  195.   x += (FWIDTH * 8);
  196.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> dblk[i].use);
  197.   x += (FWIDTH * 7);
  198.   temp_int = (int) ((
  199.               (float) ((float) current_server -> mystreams -> dblk[i].use / (float) configured)) * 100);
  200.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, temp_int);
  201.   x += (FWIDTH * 7);
  202.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%10ld", colorNumeric.pixel, current_server -> mystreams -> dblk[i].total);
  203.   x += (FWIDTH * 10);
  204.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> dblk[i].max);
  205.   x += (FWIDTH * 7);
  206.  
  207.   if (current_server -> mystreams -> dblk[i].fail > 0)
  208.     pixel = colorNumericAlarm.pixel;
  209.   else
  210.     pixel = colorNumeric.pixel;
  211.  
  212.   disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", pixel, current_server -> mystreams -> dblk[i].fail);
  213.  
  214. }
  215.  
  216. /*+-------------------------------------------------------------------------
  217.     update_streams()
  218. --------------------------------------------------------------------------*/
  219. void
  220. update_streams (SP)
  221.      struct NetworkXswStruct *SP;
  222.  
  223. {
  224.   Window          window = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].window;
  225.   Display        *display = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].display;
  226.   GC              gc = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].gc;
  227.   XWindowAttributes DrawAreaXYWH = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].DrawAreaXYWH;
  228.   Pixmap          pixmap = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].pixmap;
  229.  
  230.   register int    x = 0;
  231.   register int    y = FHEIGHT;
  232.   int             fheight = FHEIGHT;
  233.   unsigned long   pixel;
  234.  
  235.   int             temp_int;
  236.  
  237.   int             dblk_tot_config;
  238.   int             i;
  239.  
  240.   int          nclass;
  241.  
  242. /*
  243.   y = streams_tly + fheight;
  244.   x = streams_tlx;
  245. */
  246.  
  247. #ifdef XSW32v5
  248. #ifdef STILLWORKINGHERE
  249.   if (must_be_32v5)
  250.  
  251.     {
  252.  
  253.       for (i = 0; i < 15; i++)
  254.     {
  255.       x = streams_tlx;
  256.  
  257.       disp_text (window, display, gc, DrawAreaXYWH, pixmap,
  258.              x, y, colorLabel.pixel,
  259.              mystream_list32v5[i].stream_name);
  260.       x += (FWIDTH * 23);
  261.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams32v5 -> alc[i]);
  262.  
  263.       y += fheight;
  264.     }
  265.  
  266.     }
  267.   else
  268. #endif
  269. #endif
  270.     {
  271.  
  272. /* NSTREAM */
  273. /*
  274.       x = streams_tlx;
  275. */
  276.       disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, colorLabel.pixel, "NSTREAM         ");
  277.       x += (FWIDTH * 16);
  278.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorStaticNumeric.pixel, current_server -> my_v -> v_nstream);
  279.       x += (FWIDTH * 8);
  280.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> stream.use);
  281.       x += (FWIDTH * 7);
  282.       temp_int = (int) (((float) current_server -> mystreams -> stream.use / current_server -> my_v -> v_nstream) * 100);
  283.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, temp_int);
  284.       x += (FWIDTH * 7);
  285.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%10ld", colorNumeric.pixel, current_server -> mystreams -> stream.total);
  286.       x += (FWIDTH * 10);
  287.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> stream.max);
  288.       x += (FWIDTH * 7);
  289.  
  290.       if (current_server -> mystreams -> stream.fail > 0)
  291.     pixel = colorNumericAlarm.pixel;
  292.       else
  293.     pixel = colorNumeric.pixel;
  294.  
  295.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", pixel, current_server -> mystreams -> stream.fail);
  296. /* NQUEUE */
  297.       y += fheight;
  298.       x = streams_tlx;
  299.       disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, colorLabel.pixel, "NQUEUE          ");
  300.       x += (FWIDTH * 16);
  301.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorStaticNumeric.pixel, current_server -> my_v -> v_nqueue);
  302.       x += (FWIDTH * 8);
  303.  
  304. /*
  305.       fprintf (stdout, "queue.use = %d \n", current_server -> mystreams -> queue.use);
  306. */
  307.  
  308.       current_server -> mystreams -> queue.use =
  309.         current_server -> mystreams -> queue.use * 2;
  310.  
  311.       current_server -> mystreams -> queue.max =
  312.         current_server -> mystreams -> queue.max * 2;
  313.  
  314.  
  315.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> queue.use);
  316.       x += (FWIDTH * 7);
  317.       temp_int = (int) (((float) current_server -> mystreams -> queue.use / current_server -> my_v -> v_nqueue) * 100);
  318.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, temp_int);
  319.       x += (FWIDTH * 7);
  320.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%10ld", colorNumeric.pixel, current_server -> mystreams -> queue.total);
  321.       x += (FWIDTH * 10);
  322.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> queue.max);
  323.       x += (FWIDTH * 7);
  324.  
  325.       if (current_server -> mystreams -> queue.fail > 0)
  326.     pixel = colorNumericAlarm.pixel;
  327.       else
  328.     pixel = colorNumeric.pixel;
  329.  
  330.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", pixel, current_server -> mystreams -> queue.fail);
  331.  
  332.  
  333. /* MBLOCK */
  334.       x = streams_tlx;
  335.       y += fheight;
  336.       disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, colorLabel.pixel, "MBLOCK          ");
  337.       x += (FWIDTH * 16);
  338.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorStaticNumeric.pixel, *current_server -> mynmblock);
  339.       x += (FWIDTH * 8);
  340.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> mblock.use);
  341.       x += (FWIDTH * 7);
  342.       temp_int = (int) ((
  343.               (float) ((float) current_server -> mystreams -> mblock.use / *current_server -> mynmblock)) * 100);
  344.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, temp_int);
  345.       x += (FWIDTH * 7);
  346.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%10ld", colorNumeric.pixel, current_server -> mystreams -> mblock.total);
  347.       x += (FWIDTH * 10);
  348.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> mblock.max);
  349.       x += (FWIDTH * 7);
  350.  
  351.       if (current_server -> mystreams -> mblock.fail > 0)
  352.     pixel = colorNumericAlarm.pixel;
  353.       else
  354.     pixel = colorNumeric.pixel;
  355.  
  356.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", pixel, current_server -> mystreams -> mblock.fail);
  357.  
  358.  
  359. /* DBLOCK */
  360.  
  361.     if ( current_server -> os_version == 0 )
  362.     {
  363.       dblk_tot_config = current_server -> my_v -> v_nblk4 + current_server -> my_v -> v_nblk16 + current_server -> my_v -> v_nblk64 + current_server -> my_v -> v_nblk128 +
  364.     current_server -> my_v -> v_nblk256 + current_server -> my_v -> v_nblk512 + current_server -> my_v -> v_nblk1024 +
  365.     current_server -> my_v -> v_nblk2048 + current_server -> my_v -> v_nblk4096;
  366.       x = streams_tlx;
  367.       y += fheight;
  368.       disp_text (window, display, gc, DrawAreaXYWH, pixmap, x, y, colorLabel.pixel, "DBLK  TOT       ");
  369.       x += (FWIDTH * 16);
  370.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorStaticNumeric.pixel, dblk_tot_config);
  371.       x += (FWIDTH * 8);
  372.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> dblock.use);
  373.       x += (FWIDTH * 7);
  374.       temp_int = (int) ((
  375.               (float) ((float) current_server -> mystreams -> dblock.use / (float) dblk_tot_config)) * 100);
  376.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, temp_int);
  377.       x += (FWIDTH * 7);
  378.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%10ld", colorNumeric.pixel, current_server -> mystreams -> dblock.total);
  379.       x += (FWIDTH * 10);
  380.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", colorNumeric.pixel, current_server -> mystreams -> dblock.max);
  381.       x += (FWIDTH * 7);
  382.  
  383.       if (current_server -> mystreams -> dblock.fail > 0)
  384.     pixel = colorNumericAlarm.pixel;
  385.       else
  386.     pixel = colorNumeric.pixel;
  387.  
  388.       disp_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "%7ld", pixel, current_server -> mystreams -> dblock.fail);
  389.  
  390.      }
  391.  
  392.  
  393.       if ( current_server -> os_version == 0 )
  394.     nclass = 9;
  395.       else
  396.       if ( current_server -> os_version == 1 )
  397.     nclass = 15;
  398.      
  399.       for (i = 0; i < nclass; i++)
  400.     {
  401.       x = streams_tlx;
  402.       y += fheight;
  403.       update_streams_buffers (window, display, gc, DrawAreaXYWH, pixmap, x, y, i);
  404.  
  405.     }
  406.  
  407.     }
  408.  
  409.  
  410. }                /* end of update_streams */
  411.  
  412. /*+-------------------------------------------------------------------------
  413.     draw_streams_literals(x,y)
  414. --------------------------------------------------------------------------*/
  415. void
  416. draw_streams_literals (SP)
  417.      struct NetworkXswStruct *SP;
  418. {
  419.   Window          window = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].window;
  420.   Display        *display = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].display;
  421.   GC              gc = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].gc;
  422.   XWindowAttributes DrawAreaXYWH = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].DrawAreaXYWH;
  423.   Pixmap          pixmap = SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].pixmap;
  424.  
  425.   int             x = 0;
  426.   int             y = 0;
  427.  
  428.  
  429.   int             x2 = x;
  430.   int             ys = y + FASCENT;
  431.   int             yl1 = y + (FASCENT / 2) + 1;
  432.   int             yl2 = y + (FHEIGHT / 2);
  433.   int             len;
  434.   char           *cptr;
  435.   int             fheight = FHEIGHT;
  436.   int             fwidth = FWIDTH;
  437.   int             line_style = LineSolid;
  438.   int             cap_style = CapButt;
  439.   int             join_style = JoinMiter;
  440.  
  441.   streams_tlx = x;
  442.   streams_tly = y;
  443.  
  444.   /* the "background" color */
  445.   XSetForeground (display, gc, colorTitleBarBG.pixel);
  446.   XSetLineAttributes (display, gc, fheight,
  447.               line_style, cap_style, join_style);
  448. /*
  449.   XDrawLine (display, window, gc, x, yl2, DrawAreaXYWH.width - BORDER_EXTRA_WIDTH  , yl2);
  450. */
  451.   XDrawLine (display, pixmap, gc, x, yl2, SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].width - BORDER_EXTRA_WIDTH, yl2);
  452.  
  453.   /* "-Streams    Config    Use    %Use ... -" */
  454.   XSetForeground (display, gc, colorTitleBarFG.pixel);
  455.   XSetLineAttributes (display, gc, FASCENT / 2,
  456.               line_style, cap_style, join_style);
  457. /*
  458.   XDrawLine (display, window, gc,
  459.          x2, yl1,
  460.          x2 + (len = (fwidth * 5)) - FGAP, yl1);
  461. */
  462.   XDrawLine (display, pixmap, gc,
  463.          x2, yl1,
  464.          x2 + (len = (fwidth * 5)) - FGAP, yl1);
  465.   x2 += len;
  466.  
  467.   if (must_be_32v5)
  468.     cptr = "Streams     Count      Pages Total    Max   Fail";
  469.   else
  470.     cptr = "Streams     Config     Use   %Use     Total    Max   Fail";
  471.  
  472. /*
  473.   XDrawString (display, window, gc, x2, ys, cptr, len = strlen (cptr));
  474.   XDrawString (display, window, gc, x2 + 1, ys, cptr, len);
  475. */
  476.   XDrawString (display, pixmap, gc, x2, ys, cptr, len = strlen (cptr));
  477.   XDrawString (display, pixmap, gc, x2 + 1, ys, cptr, len);
  478.   x2 += (fwidth * len) + FGAP + 1;
  479. /*
  480.   XDrawLine (display, window, gc, x2, yl1, DrawAreaXYWH.width - BORDER_EXTRA_WIDTH , yl1);
  481. */
  482.   XDrawLine (display, window, gc, x2, yl1, SP -> SEPERATE_WINDOWS_LIST[BUTTON_streams].width - BORDER_EXTRA_WIDTH, yl1);
  483.  
  484. }                /* end of draw_streams_literals */
  485.  
  486. /* vi: set tabstop=4 shiftwidth=4: */
  487. /* end of sysinfo.c */
  488.